package drawer

import "MetroBuilderGameJam/gameEngine/geom"

func (d *Drawer) applyAnchor(p geom.Vec2, size geom.Size) geom.Vec2 {
	switch d.Anchor {
	case AnchorTopLeft:
		return p.Add(size.AsVec2())
	case AnchorTop:
		return p.Add(geom.NewVec2(0, size.Height))
	case AnchorBottom:
		return p.Sub(geom.NewVec2(0, size.Height))
	case AnchorLeft:
		return p.Add(geom.NewVec2(size.Width, 0))
	case AnchorRight:
		return p.Sub(geom.NewVec2(size.Width, 0))
	case AnchorTopRight:
		return p.Add(geom.NewVec2(-size.Width, size.Height))
	case AnchorBottomLeft:
		return p.Add(geom.NewVec2(size.Width, -size.Height))
	case AnchorBottomRight:
		return p.Sub(size.AsVec2())
	default:
		return p
	}
}
